package com.sky.controller.user;


import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.DishService;
import com.sky.service.SetmealService;
import com.sky.vo.DishItemVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("UserSetmealController")
@Slf4j
@RequestMapping("/user/setmeal")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;
    @Autowired
    private DishService dishService;

    @GetMapping("/list")
    @Cacheable(cacheNames = "setmealCache", key="#categoryId")
    public Result<List<Setmeal>> list(String categoryId) {
         log.info("查询为ID 为:{}",categoryId );
         List<Setmeal> setmeal =  setmealService.getSetmealCategoryId(categoryId);
         return Result.success(setmeal);
     }
     @GetMapping("/dish/{id}")
    public Result<List<DishItemVO>> getSetmeal(@PathVariable Integer id) {
         log.info("查询为ID 为:{}",id );
         return Result.success(dishService.getSetmealByDishId(id));
     }


}
